/**
 设备巡检接口
 **/
import { http } from "@/utils/http";

type ResultTable = {
  total?: number;
  data?: Array<any>;
};

/***************************巡检计划相关接口***************************/
// 查询巡检清单列表
export const InspectionListAPI_queryPage = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/checklist/pageList`, {
    data
  });
};

// 保存巡检清单
export const InspectionListAPI_save = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/checklist/save`, {
    data
  });
};

// 编辑巡检清单
export const InspectionListAPI_edit = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/checklist/edit`, {
    data
  });
};

// 删除巡检清单
export const InspectionListAPI_delete = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/checklist/delByChecklistIds`, { data });
};

// 根据id查看巡检清单详情
export const InspectionListAPI_By_Id = (data?: string) => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/checklist/queryByChecklistId?checklistId=${data}`);
};

// 巡检清单数据导入
export const InspectionListAPI_Import = (data?: FormData) => {
  return http.request(
    "post",
    `/digitaltwins/api/v1/checklistContent/dataImport`,
    {
      headers: {
        noLoading: true,
        "content-type": "application/x-www-form-urlencoded"
      }
    },
    { data }
  );
};

/***************************巡检计划相关接口***************************/
// 查询巡检计划列表
export const InspectionPlanAPI_queryPage = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/checkPlan/pageList`, {
    data
  });
};

// 巡检计划发行
export const InspectionPlanAPI_Execute = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/checkPlan/execute`, {
    data
  });
};

// 巡检计划保存
export const InspectionPlanAPI_Add = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/checkPlan/save`, {
    data
  });
};

// 编辑巡检计划
export const InspectionPlanAPI_edit = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/checkPlan/edit`, {
    data
  });
};

// 巡检计划删除
export const InspectionPlanAPI_Delete = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/checkPlan/delByCheckPlanIds`, {
    data
  });
};

// 根据id查看详情
export const InspectionPlanAPI_By_Id = (data?: string) => {
  return http.request("post", `/digitaltwins/api/v1/checkPlan/queryByCheckPlanId?checkPlanId=${data}`);
};

/***************************巡检任务相关接口***************************/
// 查询巡检任务列表
export const InspectionTaskAPI_queryPage = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/checkTask/pageList`, {
    data
  });
};
// 查询巡检任务详情
export const InspectionTaskAPI_By_Id = (data?: string) => {
  return http.request("post", `/digitaltwins/api/v1/checkTask/queryByCheckTaskId?checkTaskId=${data}`);
};
// 巡检任务审核
export const InspectionTaskAPI_Approve = (data?: string) => {
  return http.request("post", `/digitaltwins/api/v1/checkTask/approve`, {
    data
  });
};

/***************************巡检记录相关接口***************************/
// 查询巡检记录列表
export const InspectionLogAPI_queryPage = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/checkTask/pageCheckTaskRecord`, {
    data
  });
};
